/**
 * 
 */
package com.Qinmeiwei.web.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import com.Qinmeiwei.web.domain.Constant;

import static com.Qinmeiwei.web.domain.Constant.*;

public class LoadPathListener implements ServletContextListener {

	@Override
	public void contextInitialized(ServletContextEvent event) {
		Constant.setDomainPath(event.getServletContext().getInitParameter("domain"));
        Constant.setStaticPath(event.getServletContext().getInitParameter("static"));
        Constant.setImagesPath(event.getServletContext().getInitParameter("images"));
        Constant.setStylesPath(event.getServletContext().getInitParameter("styles"));
        Constant.setUserfilesPath(event.getServletContext().getInitParameter("userfiles"));
        
        event.getServletContext().setAttribute("domainRoot", DOMAIN_PATH);
        event.getServletContext().setAttribute("staticRoot", STATIC_PATH);
        event.getServletContext().setAttribute("imagesRoot", IMAGES_PATH);
        event.getServletContext().setAttribute("stylesRoot", STYLES_PATH);
        event.getServletContext().setAttribute("userfilesRoot", USERFILES_PATH);
    }

	@Override
	public void contextDestroyed(ServletContextEvent event) {}

}
